<?php
require_once (APPLICATION_DIR."/application/model/Alumni_news.php");
class AlumniNews
{
	function deleteNews($p_intId)
	{
		$objNews = new DataObjects_Alumni_news();
		$objNews -> id = $p_intId;
		
		return $objNews -> delete();
	}
	
	function updateNews($p_arrInfo)
	{
		$objNews = new DataObjects_Alumni_news();
		$objNews -> title = $p_arrInfo["title"];
		$objNews -> summary = $p_arrInfo["summary"];
		if ( $p_arrInfo["image"] != "" )
			$objNews -> image = $p_arrInfo["image"];
		$objNews -> detail = $p_arrInfo["detail"];
		$objNews -> status = $p_arrInfo["status"];
		$objNews -> newsletter = $p_arrInfo["newsletter"];
		$objNews -> whereAdd("id=" . $p_arrInfo["id"]);
		
		return $objNews -> update(DB_DATAOBJECT_WHEREADD_ONLY);
	}
	function getInfoNews($p_intId)
	{
		$objNews = new DataObjects_Alumni_news();
		$objNews -> selectAdd();
		$objNews -> selectAdd('*');
		$objNews -> whereAdd("id=" . $p_intId);
		$arrTmp = $objNews -> fetchList();
		
		if ( count($arrTmp) )
			return $arrTmp[0];
		else
			return false;
	}

	function addNews($p_arrInfo)
	{
		$objNews = new DataObjects_Alumni_news();
		$objNews -> title = $p_arrInfo["title"];
		$objNews -> summary = $p_arrInfo["summary"];
		$objNews -> image = $p_arrInfo["image"];
		$objNews -> detail = $p_arrInfo["detail"];
		$objNews -> status = $p_arrInfo["status"];
		$objNews -> newsletter = $p_arrInfo["newsletter"];
		$objNews -> created = date("Y-m-d H:i:s");
		
		return $objNews -> insert();
	}
	
	function getListNews($p_intStart, $p_intLimit)
	{
		$objNews = new DataObjects_Alumni_news();
		
		$objNews -> limit($p_intStart, $p_intLimit);
		$objNews -> find();
		return $objNews;
	}
}
?>